<template>
  <div>
    <div
      class="hongbaomask"
      :style="{ height: clientHeight + 'px' }"
      ref="homePage"
    >
      <img
        src="http://o6wndwjxn.qnssl.com/57652201812141354004977.png"
        alt=""
        class="hongbao_img"
      >
      <div class="hongbao_tit">恭喜您抢到 <div class="hongbao_nr">优惠券红包</div>
      </div>
      <div class="hongbao_price">
        <div class="hongbao_num">2.15</div>元
      </div>
      <div class="hongbao_wz">速度求助</div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      clientHeight: '',
      clientWidth: ''
    }
  },
  mounted () {
    // 获取浏览器可视区域高度
    this.clientHeight = `${document.documentElement.clientHeight}` // document.body.clientWidth;
    this.clientWidth = `${document.documentElement.clientWidth}` // document.body.clientWidth;
//     console.log(this.clientHeight)
//     console.log(this.clientWidth)
    window.onresize = function temp () {
      this.clientHeight = `${document.documentElement.clientHeight}`
    }
  },
  watch: {
    clientHeight: function () {
      this.changeFixed(this.clientHeight)
    }
  },
  methods: {
    changeFixed (clientHeight) { // 动态修改样式
      this.$refs.homePage.style.height = clientHeight + 'px'
    }
  }
}

</script>
<style>
.hongbaomask {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 99999999999;
}
.hongbao_img {
  width: 257px;
  height: 275px;
  position: absolute;
  top: 103px;
  right: 16%;
}
.hongbao_wz {
  width: 215px;
  height: 29px;
  background-color: #fee94e;
  border-radius: 4px;
  text-align: center;
  font-family: PingFangSC-Regular;
  font-size: 15px;
  line-height: 29px;
  font-weight: normal;
  font-stretch: normal;
  color: #db483c;
  position: absolute;
  top: 400px;
  right: 22%;
}
.hongbao_tit {
  font-family: PingFangSC-Medium;
  font-size: 12px;
  font-weight: bold;
  font-stretch: normal;
  letter-spacing: 0px;
  color: #7a2716;
  position: absolute;
  top: 173px;
  right: 31%;
}
.hongbao_nr {
  display: inline-block;
  font-family: PingFangSC-Medium;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0px;
  color: #db483c;
}
.hongbao_price {
  font-family: MicrosoftYaHei;
  font-size: 22px;
  letter-spacing: 0px;
  font-weight: bold;
  color: #db483c;
  position: absolute;
  top: 210px;
  right: 34%;
}
.hongbao_num {
  display: inline-block;
  font-size: 44px;
}
</style>
